package edu.cuit.avatar;

public class MathTest {
    public static void main(String[] args) {
        //ceil: 向上取整(返回不小于该数的最小的整数)
        System.out.println(Math.ceil(2.3)); //3
        System.out.println(Math.ceil(2.8)); //3
        System.out.println(Math.ceil(-2.8)); //-2

        //floor: 向下取整(返回不大于该数的最大的整数)
        System.out.println(Math.floor(2.3)); //2
        System.out.println(Math.floor(2.8)); //2
        System.out.println(Math.floor(-2.8)); //-3

        //round: 四舍五入
        System.out.println(Math.round(2.3)); //2
        System.out.println(Math.round(2.8)); //3
        System.out.println(Math.round(-2.8)); //-3

        //rint(x):取最接近x的整数
        System.out.println(Math.rint(2.3));
        System.out.println(Math.rint(2.8));

        System.out.println(Math.min(2, 3));

        for(int i = 0; i < 5; i++)
            System.out.println(Math.random()); //[0,1)
    }
}
